﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace view.Action
{
    /// <summary>
    /// 登录
    /// </summary>
    public class Login : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request.HttpMethod.ToLower() == "get")
            {
                JU.Common.CommonHelper.ClearUserSession();
            }
            string loginName = context.Request.Form["loginName"].Trim();
            string loginPwd = context.Request.Form["loginPwd"];
            bool isRemember = bool.Parse(context.Request.Form["isRemember"]);
            if (loginName.Length > 0 && loginPwd.Length == 32)
            {
                if (JU.BLL.LoginManager.Login(loginName, loginPwd, isRemember))
                {
                    context.Response.Write(1);
                    context.Response.End();
                }
            }
            context.Response.Write(0);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}